package common;

import java.util.ArrayList;

import view.mainForm;

import model.FIRModel;
import model.HistoryModel;
import model.PostMotemModel;
import model.complaintModel;
import model.criminalModel;
import model.userModel;
import dao.FIRDAO;
import dao.HistoryDao;
import dao.PostMotemDao;
import dao.complaintdao;
import dao.criminalDAO;
import dao.userdao;

public class loadData {
	public static String[] columnUser={"ID","UserName","PassWord","FirstName","LastName","Sex","Birth","Address","Status","Role","Last Update"};
	public static String [][] rowUser;
	public static String[] columnPostmortem={"ID","IDHIS","NAME","AGE","Sex","IMAGE","Address","DOCTOR","RESULT","PLACE","Date","Last Update"};
	public static String [][] rowPostmortem;
	public static String[] CollunmCriminal = {"ID","FirstName","LastName","Birth","Address","Gender","Image","User","lastupdate"};
	public static String [][] rowCriminal;
	public static String [][] rowprisoner;
	public static String [][] rowmostwanted;
	public static String[] Collunmfir = {"NO.","ID","Name","Name Fir","Crime Type","Status","lastupdate"};
	public static String [][] rowfir;
	public static String[] columnComplaint={"ID","Complaint Type","Name","Age","Sex","Address","Phone","Email","Detail","Date","Place","IdUser","Last Update"};
	public static String [][] rowComplaint;
	public static String[] columnHis={"No.","ID","Name","Date","Detail","Place","Last Update"};
	public static String [][] rowHis;
	public static int tab=0;
	
	//searh
public  static void loadDatassearchComplaint(){
		
		ArrayList<complaintModel> listcom = complaintdao.getSearchComplaint(mainForm.search);
		rowComplaint = new String[listcom.size()][13];
		int row = 0;
		for (complaintModel model : listcom) {
			rowComplaint[row][0] =String.valueOf(model.getId());
			rowComplaint[row][1] = String.valueOf(model.getID_com_type());
			rowComplaint[row][2] = model.getName();
			rowComplaint[row][3] = String.valueOf(model.getAge());
			if( model.getSex()==0){
				rowComplaint[row][4] = "Female";
			}else{
				rowComplaint[row][4] ="Male";
			}

			rowComplaint[row][5] = model.getAddress();
			rowComplaint[row][6] = model.getPhone();
			rowComplaint[row][7] = model.getEmail();
			rowComplaint[row][8] = model.getDetail();
			rowComplaint[row][9] = model.getDate();
			rowComplaint[row][10] = model.getPlace();
			rowComplaint[row][11] = String.valueOf(model.getIduser());
			rowComplaint[row][12] = model.getLast_updated();
			row++;
	}
}
	
	public  static void loadDataTableUser(){
		
		ArrayList<userModel> listUser = userdao.getAlluser();
		//rowUser= new ;
		rowUser = new String[listUser.size()][11];
		int row = 0;
		//ID","UserName","PassWord","FirstName","LastName","Sex","Birth","Address","Status","Role","Last Update"
		for (userModel model : listUser) {
			rowUser[row][0] = String.valueOf(model.getId());
			rowUser[row][1] = model.getUserName();
			rowUser[row][2] = model.getPassWprd();
			rowUser[row][3] = model.getFirstName();
			rowUser[row][4] = model.getLastName();
			if( model.getSex()==0){
				rowUser[row][5] = "Female";
			}else{
				rowUser[row][5] ="Male";
			}

			rowUser[row][6] = model.getBirth_date();
			rowUser[row][7] = model.getAddress();
			if(model.getStatus()==1){
				rowUser[row][8] = "activities";
			}else if(model.getStatus()==2){
				rowUser[row][8] = "Lock";
			}
			if(model.getIdrole()==0){
				rowUser[row][9] = "Admin";
			}else if(model.getIdrole()==1){
				rowUser[row][9] = "User";
			}
			rowUser[row][10] = model.getLast_update();
			row++;
		}
	}
	//search User
public  static void loadDataSearchUser(){
		
		ArrayList<userModel> listUser = userdao.getDataSearchUser(mainForm.search);
		//rowUser= new ;
		rowUser = new String[listUser.size()][11];
		int row = 0;
		//ID","UserName","PassWord","FirstName","LastName","Sex","Birth","Address","Status","Role","Last Update"
		for (userModel model : listUser) {
			rowUser[row][0] = String.valueOf(model.getId());
			rowUser[row][1] = model.getUserName();
			rowUser[row][2] = model.getPassWprd();
			rowUser[row][3] = model.getFirstName();
			rowUser[row][4] = model.getLastName();
			if( model.getSex()==0){
				rowUser[row][5] = "Female";
			}else{
				rowUser[row][5] ="Male";
			}

			rowUser[row][6] = model.getBirth_date();
			rowUser[row][7] = model.getAddress();
			if(model.getStatus()==1){
				rowUser[row][8] = "activities";
			}else if(model.getStatus()==2){
				rowUser[row][8] = "Lock";
			}
			if(model.getIdrole()==0){
				rowUser[row][9] = "Admin";
			}else if(model.getIdrole()==1){
				rowUser[row][9] = "User";
			}
			rowUser[row][10] = model.getLast_update();
			row++;
		}
	}
	
	
	public  static void loadDataTablePostmortem(){
		ArrayList<PostMotemModel> listPost = PostMotemDao.getALL();
		
		rowPostmortem = new String[listPost.size()][12];
		int row = 0;
		for (PostMotemModel model : listPost) {
			rowPostmortem[row][0] =String.valueOf(model.getId());
			rowPostmortem[row][1] =String.valueOf(model.getIdHis());
			rowPostmortem[row][2] = model.getName();
			rowPostmortem[row][3] = String.valueOf(model.getAge());
			if(model.getSex()==0){
				rowPostmortem[row][4] = "Female";
			}else{
				rowPostmortem[row][4]="Male";
			}
			rowPostmortem[row][5] = model.getImage();
			rowPostmortem[row][6] = model.getAddress();
			rowPostmortem[row][7] = model.getDoctor();
			rowPostmortem[row][8] = model.getResult();
			rowPostmortem[row][9] = model.getPlace();
			rowPostmortem[row][10] = model.getDate();
			rowPostmortem[row][11] = model.getLastUpdated();
			row++;
		}
	}
	//data search postmortem
	public  static void loadDatasearchPostmortem(){
		ArrayList<PostMotemModel> listPost = PostMotemDao.getdataSearchPostmortem(mainForm.search);
		
		rowPostmortem = new String[listPost.size()][12];
		int row = 0;
		for (PostMotemModel model : listPost) {
			rowPostmortem[row][0] =String.valueOf(model.getId());
			rowPostmortem[row][1] =String.valueOf(model.getIdHis());
			rowPostmortem[row][2] = model.getName();
			rowPostmortem[row][3] = String.valueOf(model.getAge());
			if(model.getSex()==0){
				rowPostmortem[row][4] = "Female";
			}else{
				rowPostmortem[row][4]="Male";
			}
			rowPostmortem[row][5] = model.getImage();
			rowPostmortem[row][6] = model.getAddress();
			rowPostmortem[row][7] = model.getDoctor();
			rowPostmortem[row][8] = model.getResult();
			rowPostmortem[row][9] = model.getPlace();
			rowPostmortem[row][10] = model.getDate();
			rowPostmortem[row][11] = model.getLastUpdated();
			row++;
		}
	}
	
	public  static void datacriminal(){
		ArrayList<criminalModel> listcriminal = criminalDAO.getAllCrime();
		rowCriminal = new String[listcriminal.size()][9];
		int row = 0;
		for(criminalModel model: listcriminal){
			rowCriminal[row][0] = criminalDAO.convertID(model.getId());
			rowCriminal[row][1] = model.getFirstName();
			rowCriminal[row][2] = model.getLastName();
			rowCriminal[row][3] = model.getBirth();
			rowCriminal[row][4] = model.getAddress();
		if(model.getSex()==0){
			rowCriminal[row][5] = "Male";
		}else{
			rowCriminal[row][5] = "Female";
		}
		rowCriminal[row][6] = model.getImage();
		if(model.getIduser()==0){
			rowCriminal[row][7] = "admin";
		}else{
			rowCriminal[row][7] = "user";
		}	      
		rowCriminal[row][8] = model.getLast_Update();         
		row++;
		};
	}
	//search criminal
	public  static void datacriminalSearch(){
		ArrayList<criminalModel> listcriminal = criminalDAO.getSearchCrime(mainForm.search);
		rowCriminal = new String[listcriminal.size()][9];
		int row = 0;
		for(criminalModel model: listcriminal){
			rowCriminal[row][0] = criminalDAO.convertID(model.getId());
			rowCriminal[row][1] = model.getFirstName();
			rowCriminal[row][2] = model.getLastName();
			rowCriminal[row][3] = model.getBirth();
			rowCriminal[row][4] = model.getAddress();
		if(model.getSex()==0){
			rowCriminal[row][5] = "Male";
		}else{
			rowCriminal[row][5] = "Female";
		}
		rowCriminal[row][6] = model.getImage();
		if(model.getIduser()==0){
			rowCriminal[row][7] = "admin";
		}else{
			rowCriminal[row][7] = "user";
		}	      
		rowCriminal[row][8] = model.getLast_Update();         
		row++;
		};
	}
	
	//prisoner
	public  static void dataprisoner(){
		ArrayList<criminalModel> listcriminal = criminalDAO.getAll(1);
		rowprisoner = new String[listcriminal.size()][9];
		int row = 0;
		for(criminalModel model: listcriminal){
			rowprisoner[row][0] = criminalDAO.convertID(model.getId());
			rowprisoner[row][1] = model.getFirstName();
			rowprisoner[row][2] = model.getLastName();
			rowprisoner[row][3] = model.getBirth();
			rowprisoner[row][4] = model.getAddress();
		if(model.getSex()==0){
			rowprisoner[row][5] = "Male";
		}else{
			rowprisoner[row][5] = "Female";
		}
		rowprisoner[row][6] = model.getImage();
		if(model.getIduser()==0){
			rowprisoner[row][7] = "admin";
		}else{
			rowprisoner[row][7] = "user";
		}	      
		rowprisoner[row][8] = model.getLast_Update();         
		row++;
		};
	}
	//search prisoner
	public  static void datasearchprisoner(){
		ArrayList<criminalModel> listcriminal = criminalDAO.getSearchPrisoner(mainForm.search);
		rowprisoner = new String[listcriminal.size()][9];
		int row = 0;
		for(criminalModel model: listcriminal){
			rowprisoner[row][0] = criminalDAO.convertID(model.getId());
			rowprisoner[row][1] = model.getFirstName();
			rowprisoner[row][2] = model.getLastName();
			rowprisoner[row][3] = model.getBirth();
			rowprisoner[row][4] = model.getAddress();
		if(model.getSex()==0){
			rowprisoner[row][5] = "Male";
		}else{
			rowprisoner[row][5] = "Female";
		}
		rowprisoner[row][6] = model.getImage();
		if(model.getIduser()==0){
			rowprisoner[row][7] = "admin";
		}else{
			rowprisoner[row][7] = "user";
		}	      
		rowprisoner[row][8] = model.getLast_Update();         
		row++;
		};
	}
	
	//most wanted
	public  static void datamostwanted(){
		ArrayList<criminalModel> listcriminal = criminalDAO.getAll(2);
		rowmostwanted = new String[listcriminal.size()][9];
		int row = 0;
		for(criminalModel model: listcriminal){
			rowmostwanted[row][0] = criminalDAO.convertID(model.getId());
			rowmostwanted[row][1] = model.getFirstName();
			rowmostwanted[row][2] = model.getLastName();
			rowmostwanted[row][3] = model.getBirth();
			rowmostwanted[row][4] = model.getAddress();
		if(model.getSex()==0){
			rowmostwanted[row][5] = "Male";
		}else{
			rowmostwanted[row][5] = "Female";
		}
		rowmostwanted[row][6] = model.getImage();
		if(model.getIduser()==0){
			rowmostwanted[row][7] = "admin";
		}else{
			rowmostwanted[row][7] = "user";
		}	      
		rowmostwanted[row][8] = model.getLast_Update();         
		row++;
		};
	}
	//search most wanted
	public  static void datasearchmostwanted(){
		ArrayList<criminalModel> listcriminal = criminalDAO.getSearchMostWanted(mainForm.search);
		rowmostwanted = new String[listcriminal.size()][9];
		int row = 0;
		for(criminalModel model: listcriminal){
			rowmostwanted[row][0] = criminalDAO.convertID(model.getId());
			rowmostwanted[row][1] = model.getFirstName();
			rowmostwanted[row][2] = model.getLastName();
			rowmostwanted[row][3] = model.getBirth();
			rowmostwanted[row][4] = model.getAddress();
		if(model.getSex()==0){
			rowmostwanted[row][5] = "Male";
		}else{
			rowmostwanted[row][5] = "Female";
		}
		rowmostwanted[row][6] = model.getImage();
		if(model.getIduser()==0){
			rowmostwanted[row][7] = "admin";
		}else{
			rowmostwanted[row][7] = "user";
		}	      
		rowmostwanted[row][8] = model.getLast_Update();         
		row++;
		};
	}
	
	//fir
	public  static void dataFir(){
		ArrayList<FIRModel> listFir = FIRDAO.getAll();
		rowfir = new String[listFir.size()][7];
		int row = 0;
		for(FIRModel model: listFir){
			rowfir[row][0] = String.valueOf(row+1);
			rowfir[row][1] = String.valueOf(model.getId());
			rowfir[row][2] = model.getFirstname()+" "+model.getName();
			rowfir[row][3] = model.getTitle_Name();
			rowfir[row][4] = model.getCrim_type();
			if(model.getStatus_crime()==0)
			{
				rowfir[row][5] = "Most Wanted";
			}else if(model.getStatus_crime()==1)
			{
				rowfir[row][5] = "Criminal";
			}else
			{
				rowfir[row][5] = "Prisoner";
			}
			rowfir[row][6] = model.getLast_Update();
		        
		row++;
		};
	}
	//Search Fir
	//fir
	public  static void dataSearchFir(){
		ArrayList<FIRModel> listFir = FIRDAO.getsearchFIR(mainForm.search);
		rowfir = new String[listFir.size()][7];
		int row = 0;
		for(FIRModel model: listFir){
			rowfir[row][0] = String.valueOf(row+1);
			rowfir[row][1] = String.valueOf(model.getId());
			rowfir[row][2] = model.getFirstname()+" "+model.getName();
			rowfir[row][3] = model.getTitle_Name();
			rowfir[row][4] = model.getCrim_type();
			if(model.getStatus_crime()==0)
			{
				rowfir[row][5] = "Most Wanted";
			}else if(model.getStatus_crime()==1)
			{
				rowfir[row][5] = "Criminal";
			}else
			{
				rowfir[row][5] = "Prisoner";
			}
			rowfir[row][6] = model.getLast_Update();
		        
		row++;
		};
	}
	
	//complaint
	public  static void loadDataTableComplaint(){
		ArrayList<complaintModel> listComplaint = complaintdao.getAllComplaint();
		
		rowComplaint = new String[listComplaint.size()][13];
		int row = 0;
		//{"ID","Complaint Type","Name","Age","Sex","Address","Phone","Email","Detail","Date","Place","IdUser","Last Update"}
		for (complaintModel model : listComplaint) {
			rowComplaint[row][0] =String.valueOf(model.getId());
			rowComplaint[row][1] = String.valueOf(model.getID_com_type());
			rowComplaint[row][2] = model.getName();
			rowComplaint[row][3] = String.valueOf(model.getAge());
			if( model.getSex()==0){
				rowComplaint[row][4] = "Female";
			}else{
				rowComplaint[row][4] ="Male";
			}

			rowComplaint[row][5] = model.getAddress();
			rowComplaint[row][6] = model.getPhone();
			rowComplaint[row][7] = model.getEmail();
			rowComplaint[row][8] = model.getDetail();
			rowComplaint[row][9] = model.getDate();
			rowComplaint[row][10] = model.getPlace();
			rowComplaint[row][11] = String.valueOf(model.getIduser());
			rowComplaint[row][12] = model.getLast_updated();
			row++;
		}
	
	}
	//his
	public  static void loadDataTablehis(){
		ArrayList<HistoryModel> listHis = HistoryDao.getALL();
		
		rowHis = new String[listHis.size()][7];
		int row = 0;
		for (HistoryModel model : listHis) {
			rowHis[row][0] =String.valueOf(row+1);
			rowHis[row][1] = String.valueOf(model.getId());
			rowHis[row][2] = model.getName();
			rowHis[row][3] = model.getDate();
			rowHis[row][4] = model.getDetail();
			rowHis[row][5] = model.getPlace();
			rowHis[row][6] = model.getLastUpdated();
			row++;
		}
	
	}
	//Search History
	public  static void loadDataSearchHis(){
		ArrayList<HistoryModel> listHis = HistoryDao.getDataSearchHIS(mainForm.search);
		
		rowHis = new String[listHis.size()][7];
		int row = 0;
		for (HistoryModel model : listHis) {
			rowHis[row][0] =String.valueOf(row+1);
			rowHis[row][1] = String.valueOf(model.getId());
			rowHis[row][2] = model.getName();
			rowHis[row][3] = model.getDate();
			rowHis[row][4] = model.getDetail();
			rowHis[row][5] = model.getPlace();
			rowHis[row][6] = model.getLastUpdated();
			row++;
		}
	
	}
	
}
